import '@babel/polyfill'
import searchCommon from './util/searchCommon.js'
import Vue from 'vue'
import App from './App.vue'
import router from './router/router'
import store from './store/store'
// import 'amfe-flexible'
import axios from './axios/axios'
import util from './util/util'
import { Message, Notice, Modal } from 'view-design'
import VueCookies from 'vue-cookies'
import Router from 'vue-router';
import VueI18n from 'vue-i18n';
import myPrint from '@/util/print'
import ViewUI from 'view-design';
// import 'view-design/dist/styles/iview.css';
import moment from 'moment'
import Viewer from 'v-viewer'
import cascaderMulti from "cascader-multi";
Vue.use(cascaderMulti);
// import 'viewerjs/dist/viewer.css'
// import './util/dataV'

import '@/filter/utils'
// import Mui from 'vue-awesome-mui';
import focusable from 'vue-tv-focusable';
// import ElementUI  from 'element-ui';
// import 'element-ui/lib/theme-chalk/index.css';
// import Avue from '@smallwei/avue';
// import '@smallwei/avue/lib/index.css';

import Vue2OrgTree from 'vue2-org-tree'
Vue.use(Vue2OrgTree);
import vant from './vant'



Vue.use(vant)
// Vue.use(ElementUI)
Vue.use(focusable);
// Vue.use(Mui);

/**
 * 全局定义数据源
 */
import variable from '@/util/const'
Vue.prototype.$variable = variable
Vue.use(Viewer);  //注册
Viewer.setDefaults({
    Options: { 'inline': true, 'button': true, 'navbar': true, 'title': true, 'toolbar': true, 'tooltip': true, 'movable': true, 'zoomable': true, 'rotatable': true, 'scalable': true, 'transition': true, 'fullscreen': true, 'keyboard': true, 'url': 'data-source' }
})
import Print from 'vue-print-nb'

import backLevel from './components/backLevel'
import bottomHandleWrap from './components/bottomHandleWrap'
import pageLeftTitle from './components/pageLeftTitle'


import '@/components/autoPlaceChildren'
import { Cascader } from 'element-ui';
Vue.component(Cascader.name, Cascader);
// Vue.use(DatePicker)

Vue.component('backLevel', backLevel)
Vue.component('bottomHandleWrap', bottomHandleWrap)
Vue.component('pageLeftTitle', pageLeftTitle)
// Vue.component('curd',curd)
// Vue.use(Print);  //注册
// 导入自定义语言包
import en from './language/en-US';
import zh from './language/zh-CN';
import tw from './language/zh-TW';

//导入view-design自带的
import iview_en from 'view-design/dist/locale/en-US';
import iview_zh from 'view-design/dist/locale/zh-CN';
import iview_tw from 'view-design/dist/locale/zh-TW';


import './directives/has'
Vue.use(Print)
Vue.use(ViewUI, {
    size: 'default',
    fontSize: "14px",
    table: {
        resizable: true
    }
});
Vue.use(searchCommon);
Vue.use(VueI18n);
Vue.locale = () => { };
const messages = {
    'en_US': Object.assign(en, iview_en),
    'zh_CN': Object.assign(zh, iview_zh),
    'zh_TW': Object.assign(tw, iview_tw),
};

// 自动设置语言 获取本机语言
const navLange = navigator.language;
const localLangel = (navLange === 'zh_CN' || navLange === 'en_US' || navLange === 'zh_TW') ? navLange : false;
window.localStorage.setItem('language', localStorage.getItem('language') ? localStorage.getItem('language') : localLangel ? localLangel : 'zh_CN')
const lang = window.localStorage.getItem('language') || localLangel || 'zh_CN';

// Create VueI18n instance with options
const i18n = new VueI18n({
    locale: lang,  // set locale
    messages  // set locale messages
});

/*解决路由重复点击问题*/
const routerPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error)
};

Vue.config.productionTip = false;

// 挂载到prototype上，在组件中可以直接使用this.axios访问
Vue.prototype.axios = axios;
// Vue.prototype.Mui = Mui;
Vue.prototype.util = util;
Vue.prototype.searchCommon = searchCommon;
Vue.prototype.$Message = Message;
Vue.prototype.$Notice = Notice;
Vue.prototype.$Modal = Modal;
Vue.prototype.$myPrint = myPrint;
Vue.use(VueCookies);
moment.locale(lang.toLocaleLowerCase())
Vue.prototype.$moment = moment;
// Vue.prototype.$echarts = echarts;
new Vue({
    router,
    store,
    i18n,
    searchCommon,
    render: h => h(App)
}).$mount('#app');
